package sg.edu.nus.iss.vmcs.system;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import sg.edu.nus.iss.vmcs.customer.CoinInputCommand;
import sg.edu.nus.iss.vmcs.customer.CoinReceiver;
import sg.edu.nus.iss.vmcs.interfaces.Command;

//This is no more needed as we have implemented the Adapter

public class CoinInputListener implements ActionListener {

	private Command coinInputCommand;
	
	public CoinInputListener(CoinReceiver receiver,MainController mc) {
		coinInputCommand = new CoinInputCommand(receiver);
	}
	
	@Override
	public void actionPerformed(ActionEvent evt) {
		coinInputCommand.execute(getCoinValue(evt));
	}

	private Object getCoinValue(ActionEvent evt){
		int coinValue = 0;
		if(evt instanceof ActionEvent){
			coinValue = Integer.parseInt(evt.getActionCommand());
		}
	return coinValue;	
	}
}
